<?php

require_once(ROOTDIR.'classes/basedb.php');

class GoodsDB extends BaseDB{
	public function insertGoods($fieldsData){
		$fieldsData = $this->_checkGoodsData($fieldsData);
		if (!$fieldsData) return null;
		$sql = "INSERT INTO tb_goods SET " . $this->_getUpdateSqlString($fieldsData);
		//echo $sql.'\n';
		$this->_db_writer->update($sql);
	}
	
	private function _checkGoodsData($data){
		if (!is_array($data) || !count($data)) return null;
		$data = $this->_checkAllowField($data,$this->getGoodsStruct());
		return $data;
	}
	
	public function getGoodsStruct(){
		return array('num_iid','title','nick','pic_url','cid','price','type','delist_time','post_fee','score','volume','click_url','commission','commission_rate','commission_num','commission_volume');
	}
	
	public function updateGoodsPid($goods_id,$taoke_url){
		$sql = "update fanwe_share_goods set taoke_url='".$taoke_url."' where goods_id=".$goods_id;
		$this->_db_writer->update($sql);
	}
}
?>